#include"http.hpp"

void Login(HttpRequest& req,HttpResponse& resp)
{
    LOG(LogLevel::INFO)<<req.Args()<<"进入处理数据的逻辑";
    std::string text="hello:"+req.Args();
    resp.SetCode(200);
    resp.SetHeader("Content-Type","text/plain");
    resp.SetHeader("Content-Length",std::to_string(text.size()));
    resp.SetText(text);

}
int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        std::cout<<"输入错误，请输入./ip port"<<std::endl;
    }
    uint16_t port=std::stoi(argv[1]);
    std::unique_ptr<Http> hserv=std::make_unique<Http>(port);
    hserv->RegisterServe("/login",Login);
    hserv->Start();
    
    return 0;
}